home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
BORL_TIP
/
TI100
/
TI204.ASC
< prev
next >
Wrap
Text File
|
1991-09-11
|
2KB
|
67 lines
PRODUCT : TURBO PASCAL NUMBER : 204
VERSION : 2.0xx
OS : PC-DOS, MS-DOS
DATE : April 1, 1986 PAGE : 1/2
TITLE : RANDOM NUMBER SEED LOCATIONS
Turbo Pascal maintains a four byte random number seed. There is
a Randomize procedure to give that seed a random value which the
function, Random, then uses to generate random values within a
specified range.
Random : r := seed;
The function Random(value) calls the following routine:
function Random(N_Max): real;
var c1, c2, r : real;
begin
c1 := exp(32 * ln(2));
c2 := exp(16 * ln(2));
r := (r * 129 * $361962E9) mod c1;
Random := r div c2 mod N_Max;
end;
The following table gives the random number seed address for most
Turbo Pascal implementations:
Random Number Seed Locations
IBM TURBO.COM 0129
IBM TURBO-87.COM 0116
Generic TURBO.COM 0129
Generic TURBO-87.COM 0116
The seed may be declared as:
Var RandomSeed: Array [0..3] Of Byte Absolute DSeg:$0129;
or:
Var RandomSeed: Array [0..1] Of Integer Absolute DSeg:$0129;
By replacing the value in the address, you can seed the random number
generator in any way you like: read it from a file; read a number
from the user; ask for the user to hit a key, and count until he
does; get the system time; or, assign a constant value. Using
constant values is useful in making statistical simulations uniform.